<?php

function message($status, $message = 'error', $data = [], $httpStatus = 200) {

  $result = [
    'code' => $status,
    'message' => $message,
    'data' => $data ?? []
  ];

  return json($result, $httpStatus);

}

function success($data = []) {
  return message(config('status.success'), '操作成功', $data);
}

function convertTime($datetime) {
  return date('Y-m-d H:i:s', strtotime($datetime));
}